package com.ruoyi.bus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WxBus;
import com.ruoyi.bus.service.IWxBusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客车信息Controller
 * 
 * @author xie
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/bus/bus")
public class WxBusController extends BaseController
{
    @Autowired
    private IWxBusService wxBusService;

    /**
     * 查询客车信息列表
     */
    //@PreAuthorize("@ss.hasPermi('bus:bus:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxBus wxBus)
    {
       // startPage();
        List<WxBus> list = wxBusService.selectWxBusList(wxBus);
        return getDataTable(list);
    }

    /**
     * 导出客车信息列表
     */
    @PreAuthorize("@ss.hasPermi('bus:bus:export')")
    @Log(title = "客车信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxBus wxBus)
    {
        List<WxBus> list = wxBusService.selectWxBusList(wxBus);
        ExcelUtil<WxBus> util = new ExcelUtil<WxBus>(WxBus.class);
        util.exportExcel(response, list, "客车信息数据");
    }

    /**
     * 获取客车信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:bus:query')")
    @GetMapping(value = "/{busID}")
    public AjaxResult getInfo(@PathVariable("busID") Long busID)
    {
        return success(wxBusService.selectWxBusByBusID(busID));
    }

    /**
     * 新增客车信息
     */
    @PreAuthorize("@ss.hasPermi('bus:bus:add')")
    @Log(title = "客车信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxBus wxBus)
    {
        return toAjax(wxBusService.insertWxBus(wxBus));
    }

    /**
     * 修改客车信息
     */
    @PreAuthorize("@ss.hasPermi('bus:bus:edit')")
    @Log(title = "客车信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxBus wxBus)
    {
        return toAjax(wxBusService.updateWxBus(wxBus));
    }

    /**
     * 删除客车信息
     */
    @PreAuthorize("@ss.hasPermi('bus:bus:remove')")
    @Log(title = "客车信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{busIDs}")
    public AjaxResult remove(@PathVariable Long[] busIDs)
    {
        return toAjax(wxBusService.deleteWxBusByBusIDs(busIDs));
    }
}
